Jane and Bob are near each other. They have cellphones. They want to play a multiplayer game on their phones. The game is held on an Internet server. Suppose the game is played on phone browsers. How do they tell the server that they want to play the same instance of that game?
One class of solutions assumes that the phones have common or complementary hardware that enables a direct (and usually wireless) connection. Like Bluetooth, NFC, RFID or WiFi. Or infrared, where by this we mean the range of infrared wavelengths typically used for TV or garage door remote controls. Given one of these hardware choices, Jane makes a direct connection to Bob's phone, passing data which is essentially an identifier of her, already known to the server. Bob connects to the server, picks the game and passes Jane's id to the server. Jane connects to the server. The server sees that Jane and Bob are connected, and that they wish to play the game, so it serves pages for the game to their phones.
Another method does not use special hardware. Jane and Bob connect their phones to the server. So Jane might be listed on a “matchmaking lobby” that shows them and others willing to play that game. Bob then picks Jane from this list and tells the server. Which then serves pages for the game to their phones.
A simpler version of the previous paragraph is possible if Jane and Bob had earlier played the game together. Then Jane might have added Bob to a buddy list, where this is stored or known to the server. Now she connects to the server. She waits for Bob to connect to the server, if he has not already done so. She goes to her buddy list, picks Bob and tells the server to start the game between her and Bob. The server sees that they are both connected, and so serves pages for the game to their phones. Here Jane does not need to search through a possibly long list of currently connected people to find Bob.
Note that a server based game might use a matchmaking method that allocates incoming users to game sessions. The decision to assign a given user to a given game session is to minimise the overall latencies (delays) of users that are in the session. This assumes that users have no wish to play with specific other users.